<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title></title>
		<meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
		<link rel="stylesheet" type="text/css" href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
		<link rel="stylesheet" type="text/css"
			href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
		<script type="text/javascript" src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>	
		<script type="text/javascript"
			src="<c:url value="/static/js/common.js"/>"></script>			
		<script>
		
			function initList(listDisplayEId) {
				$('#' + listDisplayEId).datagrid(
						{
							nowrap : false,
							striped : true,
							collapsible : true,
							remoteSort : true,
							notSelectByRow : false,
							onLoadError:function(){
								$.messager.alert('错误','获取数据失败，请与管理员联系！','error');
							}
						 
						});
			};
			$(document).ready(function() {
				initList('listDisplay');
			});
			 
			function searchInfo(){
                if($('#ordDateStart').combobox('getValue') ==''){
                    alert("起始日不能为空");
                }else if($('#ordDateEnd').datebox('getValue') ==''){
                    alert("截止日不能为空");
                }else{
                        $('#listDisplay').datagrid('load', {
                        	initFlag : 1,
                            ordDateEnd : $('#ordDateEnd').datebox('getValue'),
                            ordDateStart : $('#ordDateStart').datebox('getValue')
                        });  
                }
            }
            function tea(){
            	$('#listDisplay').datagrid('load');  
            }
            
         // 种类格式
            var turnoverTypeClass;
            $.ajax({
                async : false,
                url : "<c:url value='/turnover/turnoverTypePullDown.do?space=0'/>",
                type : "post",
                data : {
                	turnoverType : 1
                },
                success : function(data) {
                	turnoverTypeClass = data;
                    if(typeof(turnoverTypeClass)=='string'){
                    	turnoverTypeClass =JSON.parse(turnoverTypeClass);
                    }
                }
            });
            //设置种类
            function formatTurnoverType(value, row, index, field) {
                for (var i = 0; i < turnoverTypeClass.length; i++) {
                    if (value == turnoverTypeClass[i].turnoverType) {
                        return turnoverTypeClass[i].turnoverTypeName;
                    }
                }
                return "无";
            }
            //查看详细内容
            function  goDetailedContent(val,rowData,rowIndex){
                return '<a href="#" onclick="constructionManager(\'' + rowData.ordDate+ '\',\'' + rowData.custId + '\',\''+ rowData.turnValueAll+ '\',\''+ rowData.costValueAll+ '\',\''+ rowData.grossProfitRate +'\')">'+val+'</a>  '
            }
            function constructionManager(ordDate,custId,turnValueAll,costValueAll,grossProfitRate) {
            	if(grossProfitRate=="暂无"){
            		grossProfitRate=0;
            	}else{
            		grossProfitRate=grossProfitRate.toString().substring(0, grossProfitRate.toString().length-1);
            	}
                var new_win = window.open("<c:url value='/jsp/openIndexSun.jsp?url=/account/goAccountListForCustDetail.do'/>"
                		+"?ordDate="+ordDate+"&custId="+custId+"&turnValueAll="+turnValueAll+"&costValueAll="+costValueAll+"&grossProfitRate="+grossProfitRate,"sun","width=1200px,height=600px,status=no,scrollbars=yes");
                new_win.focus();
            }
		</script>
			</head>
			<body>
			<table width="98%">
			<tr><td>
            <div style="height: auto; width:1180px;background: #fafafa; padding: 5px;" class="easyui-panel" title="查询" iconCls="icon-search" collapsible="true" minimizable="false" maximizable="false" closable="false">
                    <form id="searchForm" name="searchForm" method="post" >
                        <div>
                        <table cellpadding="5">
                                <tr>
                                    <td>起始日期</td>
                                    <td><input class="easyui-datebox" editable="false" id="ordDateStart" name="ordDateStart" required="true"></input></td>
                                    <td>截止日期</td>
                                    <td><input class="easyui-datebox" editable="false" id="ordDateEnd" name="ordDateEnd" required="true"></input></td>
                                    <td><input type="button" onclick="searchInfo()" value="查询"></td>
                                </tr>
                        </table>                     
                        </div>
                    </form>
                </div>
            </td></tr>
			<tr>
			<td>
				<table id="listDisplay" title="核算列表" 
				iconCls="icon-list" singleSelect="true" idField="turnoverId"
				url="<c:url value="/account/accountListForCust.do?custId=${sessionScope.user.userId }"/>" loadMsg="请稍候......"
				pagination="true" pageSize="20"
				pageList="[10,20,30,40,50]" 
				rownumbers="true" sortOrder="asc">
				<thead>
				<tr>
				    <th field="id" width="25" align="center" checkbox="true" >
					</th> 
 					<th field="ordDate" width="80" sortable="true" >日期
					</th>
					<th field="custId" width="80" sortable="true" >客户id
                    </th>
					<th field="custName" width="80" sortable="true" >客户名
                    </th>
                    <th field="turnValueAll" width="100" sortable="true" >收入合计
                    </th>  
                    <th field="costValueAll" width="100" sortable="true" >成本合计
                    </th>   
					<th field="grossProfitRate" width="80"  sortable="true" >毛利率
					</th>	
					<th field="content" width="100"  sortable="true" formatter="goDetailedContent">查看详细内容
                    </th>   
 				</tr>
				</thead>
			</table>
			</td>
			</tr>
		</table>
	</body>
</html>